
package com.tarena.lbs.message.web.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.message.api.TriggerMessageApi;
import com.tarena.lbs.message.web.service.MsgService;
import com.tarena.lbs.pojo.message.param.RegisterTriggerMessageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 触发消息控制器类
 */
@RestController
@RequestMapping("message/triggerMessage")
@Api(tags = "模拟手机端产生触发消息接口")
@CrossOrigin
public class TriggerMessageController {
    @Autowired
    TriggerMessageApi triggerMessageApi;

    @Autowired
    MsgService msgService;

    /**
     * 模拟用户注册后，发送触发消息
     *
     * @param registerTriggerMessageParam 注册触发消息参数
     * @return Result<Boolean>对象
     * @throws JsonProcessingException JSON处理异常
     */
    @ApiOperation("模拟用户注册后，发送触发消息")

    @PostMapping("/register")
    public Result<Boolean> register(@RequestBody RegisterTriggerMessageParam registerTriggerMessageParam) throws JsonProcessingException {
        boolean result = triggerMessageApi.sendMessage(registerTriggerMessageParam);
        return new Result<>(result);
    }
}
